<template>
	<view class="msgBox">
		<!-- <view class="msgList flex-row"  @click="goList(item.id,item.type,item.url)" v-for="(item,index) in datalist" :key='item.id'>
			<view class="avatar"><image src='../../static/icon/icon_msg_zs.png'></image><text class="nums"></text></view>
			<view class="flex-col info">
				<view class="flex-row titleBox">
					<view class="title"><text>{{item.title}}</text><text class='guanfang'>官方</text></view>
					<view class="time">{{item.addTime}}</view>
				</view>
				<view class="content text-ellipsis">{{item.content}}</view>
			</view>
		</view> -->
		<view class="msgList flex-row"  @click="goList(item.id,item.type,item.url)" v-for="(item,index) in datalist" :key='item.id'>
			<view class="avatar"><image src='../../static/icon/icon_msg_zs.png'></image>
			<!-- <text class="nums"></text> -->
			</view>
			<view class="flex-col info">
				<view class="flex-row titleBox">
					<view class="title"><text>{{item.title}}</text><text class='guanfang'>官方</text></view>
					<view class="time">{{item.addTime}}</view>
				</view>
				<view class="content text-ellipsis">{{item.content}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import RongIMLib from '../../common/RongIMLib-3.0.6.2-dev.js'
	export default{
		data(){
			return{
				datalist:[],
				index:""
			}
		},
		onLoad(option) {
			this.getlist()
		},
		methods:{
			//获取助手列表
			getlist(){
				let id = uni.getStorageSync('userId')
				this.$http.get('/message/getMessageList').then(res => {
					if (res.code == '0') {
						
						this.datalist = res.data
						
					}else{
						uni.showToast({
							icon:"none",
							title:res.msg
						})
					}
				})
			},
			//助手列表详情
			goList(id,type,url){
				
				if(type == 2){
					plus.runtime.openURL(url);
					// window.location.href =url
				}else if(type==1){
					uni.navigateTo({
						url:'/pages/message/msgtext?id='+id
					})
				}
			},
			getmagList(){
				var conversationList = [];
				
				im.Conversation.getList().then(function(allConversationList) {
				  conversationList = im.Conversation.merge({
				    conversationList: conversationList,
				    updatedConversationList: allConversationList
				  }); // TODO 更新会话列表界面
				  console.log(conversationList)
				});
				// 注: 以下为示例代码, im.watch 建议单个页面只执行一次
				im.watch({
				  conversation: function(event) {
				    var updatedConversationList = event.updatedConversationList;
				    conversationList = im.Conversation.merge({
				      conversationList: conversationList,
				      updatedConversationList: updatedConversationList
				    }); // TODO 更新会话列表界面
				  }
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	html{
		background-color: #fff;
	}
	.msgBox{
		background-color: #fff;
		padding: 0 30upx;
		.msgList{
			align-items: center;
			padding: 30upx 0;
			border-bottom: 1upx solid rgba(238,238,238,1);
			.avatar{
				width: 88upx;
				height: 88upx;
				padding-right: 24upx;
				position: relative;
				>image{
					width: 88upx;
					height: 88upx;
				}
				.nums{
					position: absolute;
					width: 16upx;
					height: 16upx;
					background: #FF2727;
					border-radius: 50%;
					color: #fff;
					font-size: 22upx;
					text-align: center;
					line-height: 30upx;
					top: 0;
					right: 30upx;
				}
			}
		}
		.info{
			width: 580upx;
			.titleBox{
				justify-content: space-between;
				align-items: center;
				padding-bottom: 30upx;
				.title{
					color: #333338;
					font-size: 30upx;
					display: flex;
					flex-direction: row;
					align-items: center;
					.guanfang{
						margin-left: 13upx;
						display: block;
						// width: 57upx;
						height: 31upx;
						text-align: center;
						line-height: 31upx;
						font-size: 18upx;
						color: #fff;
						background: url(../../static/icon/img_msg_tip_bg.png) no-repeat left top;
						background-size: 100% 100%;
						padding: 0 10upx;
					}
				}
				.time{
					color: #999999;
					font-size: 22upx;
				}
			}
			.content{
				color: #666666;
				font-size: 26upx;
			}
		}
	}
</style>
